<template>
  <div class="rightbox" v-cloak>
    <h1>科室列表</h1>
    <el-table
    :data="dataList"
    border
    style="width: 96%;margin:2%">
      <el-table-column
        prop="name"
        label="名称"
      >
      </el-table-column>
      <el-table-column
        prop="price"
        label="价格"
      >
      </el-table-column>
      <el-table-column
        prop="state"
        label="状态"
        width="180">
        <template slot-scope="scope">
          <span v-if="scope.row.state == '1'">启用</span>
          <span v-if="scope.row.state == '-1'">禁用</span>
        </template>
      </el-table-column>
      <el-table-column
        prop=""
        width="300"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="Modify(scope)">修改</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data () {
    return {
      dataList: []
    }
  },
  methods: {
    getList: function () {
      var that = this
      that.$pub.open()
      axios({
        method: 'post',
        url: '/gp/Number/Index'
      })
        .then((res) => {
          that.$pub.close()
          if (res.data.code === 0) {
            that.dataList = res.data.data
          } else {
            that.$pub.failcode(that, res.data.code, res.data.data)
          }
        })
        .catch(function () {
          that.$pub.catchbox(that)
        })
    },
    Modify: function (scope) {
      var that = this
      that.$router.push({
        name: 'numberModify',
        params: {
          numberindex: scope.row.numberindex
        }
      })
    }
  },
  mounted () {
    this.getList()
  }
}
</script>
